Skip to content

fix: reuse tooltip instance for composite components (#9639) (CP: 25.2)#9640

Merged
web-padawan merged 1 commit into
25.2from
cherry-pick-9639-to-25.2-1782807474213
Jun 30, 2026
Merged

fix: reuse tooltip instance for composite components (#9639) (CP: 25.2)#9640
web-padawan merged 1 commit into
25.2from
cherry-pick-9639-to-25.2-1782807474213

Conversation

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This PR cherry-picks changes from the original PR #9639 to branch 25.2.

Original PR description

Tooltip instances should be reused when calling Tooltip.forComponent repeatedly for the same component, as introduced in #4736. This did not work for composite components: the tooltip was stored on the original component, but the lookup in Tooltip#getForElement resolves the innermost content component instead, so the cached instance was never found and a new one was created on every call.

Component composite = new MyComposite(); // extends Composite<Span>
Tooltip a = Tooltip.forComponent(composite);
Tooltip b = Tooltip.forComponent(composite);
// a != b before this fix

Store the cached tooltip on the innermost component in forComponent, so the write matches the read in getForElement (and the existing forHasTooltip, which already resolves the innermost component).

Fixes #9638


🤖 Generated with Claude Code

Tooltip instances should be reused when calling `Tooltip.forComponent`
repeatedly for the same component, as introduced in #4736. This did not
work for composite components: the tooltip was stored on the original
component, but the lookup in `Tooltip#getForElement` resolves the
innermost content component instead, so the cached instance was never
found and a new one was created on every call.

```java
Component composite = new MyComposite(); // extends Composite<Span>
Tooltip a = Tooltip.forComponent(composite);
Tooltip b = Tooltip.forComponent(composite);
// a != b before this fix
```

Store the cached tooltip on the innermost component in `forComponent`,
so the write matches the read in `getForElement` (and the existing
`forHasTooltip`, which already resolves the innermost component).

Fixes #9638

---

🤖 Generated with Claude Code

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@web-padawan
web-padawan merged commit 9c0e762 into 25.2 Jun 30, 2026
25 checks passed
@web-padawan
web-padawan deleted the cherry-pick-9639-to-25.2-1782807474213 branch June 30, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants